#include<bits/stdc++.h>
using namespace std;
int n;
int T,a[200005];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        int ans=0;
        for(int s=0;s<(1<<n);s++){
            int l1=-1,l0=-1;
            int cnt=0;
            for(int i=1;i<=n;i++){
                if(((s>>(i-1))&1)==1){
                    if(l1!=-1&&a[l1]==a[i]){
                        cnt+=a[i];
                    }
                    l1=i;
                }
                if(((s>>(i-1))&1)==0){
                    if(l0!=-1&&a[l0]==a[i]){
                        cnt+=a[i];
                    }
                    l0=i;
                }
            }
            ans=max(ans,cnt);
        }
        printf("%d\n",ans);
    }
    return 0;
}
